#
# Filename: PvcsLocal.py
# $Id: PvcsLocal.py,v 1.1 1999/08/13 12:39:54 toni Exp $
#
# defines the real call functions for the Pvcs Local interface
#
# Author: Uwe Stieber
# Copyright (c) 1998, 1999 TakeFive Software, Salzburg
#

# import the necessary modules
import vcs

# some global variables
from vcs import TEST

# call the put command
def put(*arguments):
	if TEST:
		print "(@B@I%s@I@B)@B@g>>>@x put" % __name__
	argumentString = ""
	# convert argument tuple to string
	for seq in arguments:
		for aArgument in seq:
			argumentString = "%s %s" % (argumentString, aArgument)
	if TEST:
		print "(@B@I%s@I@B)\targumentString = '%s'" % (__name__, argumentString)
		print "(@B@I%s@I@B)\texecute command: put %s" % (__name__, argumentString)
	rc = vcs.system("put %s" % argumentString)
	if TEST:
		print "(@B@I%s@I@B)@B@r<<<@x put (%d)" % (__name__, rc)
	return rc

# call the get command
def get(*arguments):
	if TEST:
		print "(@B@I%s@I@B)@B@g>>>@x get" % __name__
	argumentString = ""
	# convert argument tuple to string
	for seq in arguments:
		for aArgument in seq:
			argumentString = "%s %s" % (argumentString, aArgument)
	if TEST:
		print "(@B@I%s@I@B)\targumentString = '%s'" % (__name__, argumentString)
		print "(@B@I%s@I@B)\texecute command: get %s" % (__name__, argumentString)
	rc = vcs.system("get %s" % argumentString)
	if TEST:
		print "(@B@I%s@I@B)@B@r<<<@x get (%d)" % (__name__, rc)
	return rc

# call the vcs command
def vcs_command(*arguments):
	if TEST:
		print "(@B@I%s@I@B)@B@g>>>@x vcs_command" % __name__
	argumentString = ""
	# convert argument tuple to string
	for seq in arguments:
		for aArgument in seq:
			argumentString = "%s %s" % (argumentString, aArgument)
	if TEST:
		print "(@B@I%s@I@B)\targumentString = '%s'" % (__name__, argumentString)
		print "(@B@I%s@I@B)\texecute command: vcs %s" % (__name__, argumentString)
	rc = vcs.system("vcs %s" % argumentString)
	if TEST:
		print "(@B@I%s@I@B)@B@r<<<@x vcs_command (%d)" % (__name__, rc)
	return rc

# call the vlog command
def vlog_command(*arguments):
	if TEST:
		print "(@B@I%s@I@B)@B@g>>>@x vlog_command" % __name__
	argumentString = ""
	# convert argument tuple to string
	for seq in arguments:
		for aArgument in seq:
			argumentString = "%s %s" % (argumentString, aArgument)
	if TEST:
		print "(@B@I%s@I@B)\targumentString = '%s'" % (__name__, argumentString)
		print "(@B@I%s@I@B)\texecute command: vlog %s" % (__name__, argumentString)
	out = vcs.getoutput("vlog %s" % argumentString)
	if TEST:
		print "(@B@I%s@I@B)@B@r<<<@x vlog_command" % (__name__)
	return out

# call the vlog command and returns a StringStream
def vlog_popen(*arguments):
	if TEST:
		print "(@B@I%s@I@B)@B@g>>>@x vlog_popen" % __name__
	cmd = ""
	file = ""
	# convert argument tuple to string
	seq = arguments[0]
	cmd = seq[0]
	file = seq[1]
	if TEST:
		print "(@B@I%s@I@B)\texecute command: %s %s" % (__name__, cmd, file)
	out = vcs.popen(cmd, file)
	if TEST:
		print "(@B@I%s@I@B)@B@r<<<@x vlog_popen" % (__name__)
	return out

# call the vdel command
def vdel(*arguments):
	if TEST:
		print "(@B@I%s@I@B)@B@g>>>@x vdel" % __name__
	argumentString = ""
	# convert argument tuple to string
	for seq in arguments:
		for aArgument in seq:
			argumentString = "%s %s" % (argumentString, aArgument)
	if TEST:
		print "(@B@I%s@I@B)\targumentString = '%s'" % (__name__, argumentString)
		print "(@B@I%s@I@B)\texecute command: vdel %s" % (__name__, argumentString)
	rc = vcs.system("vdel %s" % argumentString)
	if TEST:
		print "(@B@I%s@I@B)@B@r<<<@x vdel (%d)" % (__name__, rc)
	return rc

# call the vdiff command
def vdiff(*arguments):
	if TEST:
		print "(@B@I%s@I@B)@B@g>>>@x vdiff" % __name__
	argumentString = ""
	# convert argument tuple to string
	for seq in arguments:
		for aArgument in seq:
			argumentString = "%s %s" % (argumentString, aArgument)
	if TEST:
		print "(@B@I%s@I@B)\targumentString = '%s'" % (__name__, argumentString)
		print "(@B@I%s@I@B)\texecute command: vdiff %s" % (__name__, argumentString)
	rc = vcs.system("vdiff %s" % argumentString)
	if TEST:
		print "(@B@I%s@I@B)@B@r<<<@x vdiff (%d)" % (__name__, rc)
	return rc

# call the diff command
def diff(*arguments):
	if TEST:
		print "(@B@I%s@I@B)@B@g>>>@x diff" % __name__
	argumentString = ""
	# convert argument tuple to string
	for seq in arguments:
		for aArgument in seq:
			argumentString = "%s %s" % (argumentString, aArgument)
	if TEST:
		print "(@B@I%s@I@B)\targumentString = '%s'" % (__name__, argumentString)
		print "(@B@I%s@I@B)\texecute command: diff %s" % (__name__, argumentString)
	out = vcs.getoutput("diff %s" % argumentString)
	if TEST:
		print "(@B@I%s@I@B)@B@r<<<@x diff" % (__name__)
	return out
